package com.jk.controller;

import com.alibaba.fastjson.JSON;
import com.jk.entity.BankCardEntity;
import com.jk.entity.BusinessEntity;
import com.jk.entity.RedisEntity;
import com.jk.pojo.UserBean;
import com.jk.service.UserService;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @ClassName UserController
 * @Descripttion TODO
 * @Author DELL
 * @Date 2022/11/2 15:24
 * @Version 0.001
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
    * @Author: binzi
    * @Description:走mysql模糊登录
    * @Date: 2022/11/2 15:33
    * @Return: java.util.Map
    **/
    @RequestMapping("login")
    public Map login(UserBean user, HttpSession session){
        return userService.login(user,session);
    }

    @RequestMapping("getRedisList")
    public List<RedisEntity> getRedisList(HttpSession session){
        return userService.getRedisList(session);
    }


    /**
    * @Author: binzi
    * @Description:短信验证接口
    * @Date: 2022/11/4 16:28
    * @Return: java.lang.Object
    **/
    @RequestMapping("smsverification")
    public void SmsVerificationOne(@Param("phone") String phone,HttpSession session) {
         userService.SmsVerificationOne(phone,session);
    }
    /*
    *
     * @Author 位佳生
     * @Description //TODO 注册用户
     * @Date 2022/11/4 17:08
     * @param phone:
     * @return: null
     **/
    @RequestMapping("registeredUser")
     public Map registeredUser(UserBean userBean,String code){
        return  userService.registeredUser(userBean,code);
     }
     /*
     *
      * @Author 位佳生
      * @Description //TODO 查询验证码是否正确和账号是否存在
      * @Date 2022/11/4 19:26
      * @param null: 
      * @return: null
      **/
     @RequestMapping("updateUserPwd")
     public Map updatePwd(UserBean userBean,String code){
         return  userService.updatePwd(userBean,code);
     }
     /*
     *
      * @Author 位佳生
      * @Description //TODO 修改密码
      * @Date 2022/11/7 11:16
      * @param session:
      * @return: java.lang.Boolean
      *
      **/
     @RequestMapping("updateUserPassward")
     public Map updateUserPassward(UserBean userBean){
          return userService.updateUserPassward(userBean);
     }
     /*
     *
      * @Author 位佳生
      * @Description //TODO 查询有无用户登录
      * @Date 2022/11/4 19:33
      * @param null: 
      * @return: null
      **/
    @RequestMapping("getSessionUser")
    public Boolean getSessionUser(HttpSession session){
        return userService.getSessionUser(session);
    }

    /**
    * @Author: binzi
    * @Description:银行卡充值
    * @Date: 2022/11/8 9:38
    * @Return: java.util.Map
    **/
    @RequestMapping("bankCardTopUp")
    public Map bankCardTopUp(BusinessEntity businessEntity){
        return userService.bankCardTopUp(businessEntity);
    }
    /*
    *
     * @Author 位佳生
     * @Description //TODO 查询当前有无用户登录
     * @Date 2022/11/9 14:42
     
     * @return: com.jk.pojo.UserBean
     **/
    @RequestMapping("selectUserEntity")
    public UserBean selectUserEntity(){
        return userService.selectUserEntity();
    }


    /**
    * @Author: binzi
    * @Description:根据手机号查询对应的银行卡号
    * @Date: 2022/11/8 11:24
    * @Return: java.util.Map
    **/
    @RequestMapping("findBankCardByPhone")
    public Map  findBankCardByPhone(){
        return userService.findBankCardByPhone();
    }
    
    /*
    *
     * @Author 位佳生
     * @Description //TODO 退出登录
     * @Date 2022/11/10 9:30
     
     * @return: java.lang.Boolean
     **/
    @RequestMapping("removeUser")
    public Boolean removeUser(HttpSession session){
        return  userService.removeUser(session);
    }


    /**
    * @Author: binzi
    * @Description:获取登录用户人信息
    * @Date: 2022/11/10 9:41
    * @Return: java.util.Map
    **/
    @RequestMapping("findUserByPhone")
    public Map findUserByPhone(){
        return userService.findUserByPhone();
    }

    /**
    * @Author: binzi
    * @Description:根据登录的用户修改支付密码
    * @Date: 2022/11/10 10:31
    * @Return: java.util.Map
    **/
    @RequestMapping("updateUserWith")
    public Map updateUserWith(String user_with){
        return userService.updateUserWith(user_with);
    }

    /**
    * @Author: binzi
    * @Description:新增银行卡号
    * @Date: 2022/11/10 11:39
    * @Return: java.util.Map
    **/
    @RequestMapping("insertBankCard")
    public Map insertBankCard(BankCardEntity bankCardEntity) throws IOException {
        return userService.insertBankCard(bankCardEntity);
    }
    
    /*
    *
     * @Author 位佳生
     * @Description //TODO 查询银行卡是否存在
     * @Date 2022/11/15 19:45
     * @param null: 
     * @return: null
     **/
    @RequestMapping("findcard")
    public Map findcard(String cardNo) throws IOException {

        return  userService.finndcard(cardNo);
    }


    /*
    *
     * @Author 位佳生
     * @Description //TODO 计算总资产
     * @Date 2022/11/10 11:20
     * @param null:
     * @return: null
     **/
    @RequestMapping("sumPrice")
    public Map sumPrice(){
        return userService.sumPrice();
    }
    /*
     *
     * @Author 位佳生
     * @Description //TODO 计算投资中本金
     * @Date 2022/11/10 11:20
     * @param null:
     * @return: null
     **/
    @RequestMapping("sumMoney")
    public Map sumMoney(){
        return userService.sumMoney();
    }
    /*
     *
     * @Author 位佳生
     * @Description //TODO 计算历史到账收益
     * @Date 2022/11/10 11:20
     * @param null:
     * @return: null
     **/
    @RequestMapping("sumCountMoney")
    public Map sumCountMoney(){
        return userService.sumCountMoney();
    }
}
